package model.entity;

import model.enums.ItemType;

import java.util.Objects;

/**
 * 商品实体类
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/25 9:11
 */
public class Item {
    /**
     * 商品id
     */
    private String id;
    /**
     * 商品名称
     */
    private String name;
    /**
     * 价格
     */
    private Double price;
    /**
     * 类型
     */
    private ItemType type;

    public Item() {
    }

    public Item(String id, String name, Double price, ItemType type) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public ItemType getType() {
        return type;
    }

    public void setType(ItemType type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Item{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", price=" + price +
                ", type=" + type +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Item item = (Item) o;
        return id.equals(item.id) && name.equals(item.name) && price.equals(item.price) && type == item.type;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, price, type);
    }
}
